package com.dhl.cloud.course.service;


import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.dhl.cloud.common.util.DateUtils;
import com.dhl.cloud.course.dao.LessionFileMapper;
import com.dhl.cloud.course.entity.LessionFile;

@Service
public class LessionFileService {
	@Autowired
	private LessionFileMapper lessionFileMapper;
 
	public List<LessionFile> selectByLessionid(Integer lessionid) {
		return lessionFileMapper.selectByLessionid(lessionid);
	}
	
	public int deleteByPrimaryKey(Integer id) {
		return lessionFileMapper.deleteByPrimaryKey(id);
	}
	
	public int insert(LessionFile c) {
		if (c.getId() != null)
		{
			LessionFile cc = lessionFileMapper.selectByPrimaryKey(c.getId());
			cc.setName(c.getName());
			cc.setFilename(c.getFilename());
			cc.setFilesize(c.getFilesize());
			cc.setFilepath(c.getFilepath());
			cc.setModifytime(DateUtils.getDateTime());
			return lessionFileMapper.updateByPrimaryKey(cc);
		}
		else
		{
			c.setCreatetime(DateUtils.getDateTime());
			return lessionFileMapper.insert(c);
		}
		
	}
}
